import request from '@/utils/request'

// 查询权限资源列表
export function fetchResList(systemId) {
  // console.log('----查询权限资源列表------')

  return request({
    url: '/authority/auResources/queryList',
    method: 'get',
    params: { systemId }
  })
}

// 权限资源明细
export function fetchDetail(resourceId, systemId) {
  return request({
    url: '/authority/auResources/detail',
    method: 'get',
    params: { resourceId, systemId }
  })
}

// 权限资源明细 (权限资源是否可见)
export function setVisiable(isVisiable, resourceId, systemId) {
  return request({
    url: '/authority/auResources/visiable',
    method: 'put',
    params: { isVisiable, resourceId, systemId }
  })
}

// 添加权限资源
export function createAdd(data) {
  return request({
    url: '/authority/auResources/add',
    method: 'post',
    data: {
      'sysId': data.sysId,
      'iconUrl': data.iconUrl,
      'isVisible': data.isVisible,
      'parentId': data.parentId,
      'resourceId': data.resourceId,
      'resourceName': data.resourceName,
      'resourceSort': data.resourceSort,
      'resourceType': data.resourceType,
      'resourceUrl': data.resourceUrl,
      'isDel': data.isDel
    }
  })
}

// 修改权限资源
export function updateArticle(data) {
  return request({
    url: '/authority/auResources/update',
    method: 'put',
    data: {
      'sysId': data.sysId,
      'iconUrl': data.iconUrl,
      'isVisible': data.isVisible,
      'parentId': data.parentId,
      'resourceId': data.resourceId,
      'resourceName': data.resourceName,
      'resourceSort': data.resourceSort,
      'resourceType': data.resourceType,
      'resourceUrl': data.resourceUrl,
      'isDel': data.isDel
    }
  })
}

// 预览权限资源
export function preResources(data) {
  return request({
    url: '/authority/auResources/view',
    method: 'get',
    data
  })
}

